package com.example.demo.config;

import com.example.demo.util.DBConnectUtil;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.sql.Connection;

@Data
@Component
@ConfigurationProperties(prefix = "spring.datasource")
public class DataSourceConfig {
    private String url;
    private String driverClassName;
    private String username;
    private String password;


    private DataSourceConfig() {
    }


    public Connection buildConnection() {
        return DBConnectUtil.getConnection(url, username, password);
    }


}
